package fr.upmc.mdoc.tp1.forms;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;

/**
 * Servlet implementation class Modifier
 */
public class EditContactForm extends ActionForm {
	private static final long serialVersionUID = 1L;

	
	
	public ActionErrors validate(ActionMapping mapping,
			HttpServletRequest request) {

		ActionErrors errors = new ActionErrors();

		try {
			int idContact = Integer.valueOf(request.getAttribute("id")
					.toString());
			request.setAttribute("id", idContact);

		} catch (Exception e) {
			errors.add("Erreur id sur URL", new ActionMessage(
					"La valeur de l'id n'est pas un entier"));
			e.printStackTrace();
		}
		return errors;
	}
}
